<?php
require_once 'constants.php';
require_once 'db.php';

$id = $_GET['img_id'];
$row = dbGetImageById($id);
$img = imagecreatefromstring($row['image']);

//Turn on output buffering, this is done to determine the true size of the
//content before sending it out to the browser
ob_start();

//Output the image to the buffer
imagejpeg($img);

//Add custom headers here
header('Content-Length: ' . ob_get_length());
header('Content-type: image/jpg');

// Free up memory
imagedestroy($img);
?>
